package cn.com.klun.tjy.other.jvm;

public class ReferenceCountingGC {
    public Object instance = null;
    private static final int _1MB = 1024*1024;
    private byte[] bigSize  = new byte[2*_1MB];
    public static void testGC(){

        ReferenceCountingGC ObjA = new ReferenceCountingGC();
        ReferenceCountingGC ObjB = new ReferenceCountingGC();
        ObjA.instance = ObjA;
        ObjB.instance = ObjB;
        ObjA = null;
        ObjB = null;
        System.gc();

    }


    public static void main(String[] args) {
        Integer a = 1;
        Integer b = 2;
        Integer c = 3;
        Integer d = 3;
        Integer e = 321;
        Integer f = 321;
        Long g = 3L;
        System.out.println(c == d);
        System.out.println(e == f);//false
        System.out.println(c == (a+b));//true
        System.out.println(c.equals(a+b));//true
        System.out.println(g == (a+b));//true
        System.out.println(g.equals(a+b));//false
    }

}
